package com.vote.admin.controller;

import com.vote.admin.service.AdminLoginService;
import com.vote.admin.service.AdminMainService;
import com.vote.admin.vo.param.LoginParam;
import com.vote.common.entity.VoteMenu;
import com.vote.common.returns.RespEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/admin-login")
@Slf4j
@Api(value = "管理平台登陆页面", tags = "管理平台登陆页面")
public class AdminLoginController {

    @Resource
    private AdminLoginService adminLoginService;

    @GetMapping("/createCode")
    @ApiOperation(value = "生成验证码")
    public RespEntity createCode(HttpServletResponse response, HttpSession session) {
        RespEntity respEntity = adminLoginService.createCode(response, session);
        return respEntity;
    }

    @PostMapping("/login")
    @ApiOperation(value = "登陆")
    public RespEntity queryAllMenus(LoginParam loginParam, HttpSession session) {
        RespEntity respEntity = adminLoginService.login(loginParam, session);
        return respEntity;
    }

}
